﻿using System;
using System.Text;
using System.Web.UI;
using System.Web.Script.Serialization;

namespace FluentHtmlWriterClient
{
    class Program
    {
        static void Main(string[] args)
        {
            var jss = new JavaScriptSerializer();

            var sb = new StringBuilder();
            using(var sw = new System.IO.StringWriter(sb))
            using (var w = new HtmlTextWriter(sw))
            {
                w.Html()
                    .Head()
                        .Script()
                            .Attributes(new { type = "text/javascript"})
                            .WriteContent("var foo='bar'; \n")
                            .WriteContent("var myObj=")
                            .WriteContent(jss.Serialize(new
                            {
                                Prop1 = "Prop1Value",
                                Prop2 = "Prop2Value"
                            }) +";\n")
                        .EndTag()
                    .EndTag()
                    .Body()
                        .Div(new { @class="outer"})
                            .P()
                                .WriteContent("some content")
                            .EndTag()
                        .EndTag()
                    .EndTag()
                .EndTag();
            }


            Console.WriteLine(sb);

            Console.ReadLine();
        }
    }
}
